<template>
  <div class="container">
    <el-row
      :getter="24"
      style="
        display: flex;
        background-color: #fff;
        border: 2px solid #cecece;
        justify-content: end;
      ">
      <div class="title">项目推进主页展示</div>
      <div class="sideBar">
        <el-button style="background-color: #a7c6e5; color: #000"
          >可筛选项目</el-button
        >
        <el-button style="background-color: #a7c6e5; color: #000"
          >可筛选机构</el-button
        >
        <el-button style="background-color: #a7c6e5; color: #000"
          >可筛选人员</el-button
        >
      </div>
    </el-row>
    <el-row :getter="24" class="main">
      <div class="left">
        <div class="main_title">年度计划项目：</div>
        <div id="left_echarts"></div>
      </div>
      <div class="content">
        <div class="main_title">年度完成项目：</div>
        <div id="content_echarts">
          <div class="charts_1" style="width: 100%; height: 50%"></div>
          <div class="charts_2" style="width: 100%; height: 50%; display: flex">
            <div class="pie_1" style="width: 50%; height: 100%"></div>
            <div class="pie_2" style="width: 50%; height: 100%"></div>
          </div>
        </div>
      </div>
      <div class="right">
        <div class="main_title">进展中项目：</div>
        <div id="right_echarts"></div>
      </div>
    </el-row>
  </div>
</template>
<script>
import * as echarts from "echarts";

const option_left = {
  tooltip: {
    trigger: "axis",
    axisPointer: {
      type: "shadow",
    },
  },
  legend: {},
  grid: {
    left: "3%",
    right: "4%",
    bottom: "3%",
    containLabel: true,
  },
  xAxis: {
    type: "value",
    boundaryGap: [0, 0.01],
  },
  yAxis: {
    type: "category",
    data: ["Brazil", "Indonesia", "USA", "India", "China", "World"],
  },
  series: [
    {
      name: "2023",
      type: "bar",
      data: [18, 23, 29, 10, 13, 6],
    },
    {
      name: "2024",
      type: "bar",
      data: [19, 23, 31, 12, 13, 68],
    },
  ],
};
const option_right = {
  title: {
    text: "员工工作质量管理",
    show: true,
  },
  tooltip: {
    trigger: "axis",
    axisPointer: {
      type: "shadow",
    },
  },
  legend: {},
  grid: {
    left: "3%",
    right: "4%",
    bottom: "3%",
    containLabel: true,
  },
  xAxis: {
    type: "value",
    boundaryGap: [0, 0.01],
  },
  yAxis: {
    type: "category",
    data: ["Brazil", "Indonesia", "USA", "India", "China", "World"],
  },
  series: [
    {
      name: "2023",
      type: "bar",
      data: [18, 23, 29, 10, 13, 6],
    },
    {
      name: "2024",
      type: "bar",
      data: [19, 23, 31, 12, 13, 68],
    },
  ],
};
const option_1 = {
  title: {
    text: "项目审计质量",
    show: true,
  },
  xAxis: {
    type: "category",
    data: ["非现场", "非现场问题", "现场", "走访", "确认问题"],
  },
  yAxis: {
    type: "value",
  },
  series: [
    {
      data: [120, 200, 150, 80, 70, 110, 130],
      type: "bar",
    },
  ],
};
const option_2_1 = {
  title: {
    text: "问题个数",
    left: "center",
  },
  tooltip: {
    trigger: "item",
  },
  legend: {
    orient: "horizontal", // 设置图例水平显示
    left: "center", // 水平居中
    top: "bottom", // 设置图例在图表下方
    bottom: 10, // 可以调整距离底部的距离
  },
  series: [
    {
      name: "问题个数：",
      type: "pie",
      radius: "50%",
      data: [
        { value: 1048, name: "Search Engine" },
        { value: 735, name: "Direct" },
        { value: 580, name: "Email" },
        { value: 484, name: "Union Ads" },
        { value: 300, name: "Video Ads" },
      ],
      emphasis: {
        itemStyle: {
          shadowBlur: 10,
          shadowOffsetX: 0,
          shadowColor: "rgba(0, 0, 0, 0.5)",
        },
      },
    },
  ],
};
const option_2_2 = {
  title: {
    text: "问题金额",
    left: "center",
  },
  tooltip: {
    trigger: "item",
  },
  legend: {
    orient: "horizontal",
    left: "center", // 水平居中
    top: "bottom", // 设置图例在图表下方
    bottom: 10, // 可以调整距离底部的距离
  },
  series: [
    {
      name: "问题金额：",
      type: "pie",
      radius: "50%",
      data: [
        { value: 1048, name: "Search Engine" },
        { value: 735, name: "Direct" },
        { value: 580, name: "Email" },
        { value: 484, name: "Union Ads" },
        { value: 300, name: "Video Ads" },
      ],
      emphasis: {
        itemStyle: {
          shadowBlur: 10,
          shadowOffsetX: 0,
          shadowColor: "rgba(0, 0, 0, 0.5)",
        },
      },
    },
  ],
};

export default {
  name: "projectPushShow",
  data() {
    return {};
  },
  created() {
    this.$nextTick(() => {
      const leftChart = echarts.init(document.getElementById("left_echarts"));
      const contentChart_1 = echarts.init(document.querySelector(".charts_1"));
      const contentChart_2_1 = echarts.init(document.querySelector(".pie_1"));
      const contentChart_2_2 = echarts.init(document.querySelector(".pie_2"));
      const rightChart = echarts.init(document.getElementById("right_echarts"));
      leftChart.setOption(option_left);
      contentChart_1.setOption(option_1);
      contentChart_2_1.setOption(option_2_1);
      contentChart_2_2.setOption(option_2_2);
      rightChart.setOption(option_right);
    });
  },
};
</script>
<style scoped>
.container {
  width: 100%;
  height: 100vh;
  box-sizing: border-box;
  border: 1px solid rgb(245, 247, 249);
  box-shadow: 0 4px 8px rgba(126, 113, 113, 0.2); /* 添加阴影 */
  padding: 4px;
  display: flex;
  flex-direction: column;
}
.container .main {
  height: 100%;
  display: flex;
}
.container .main .left,
.container .main .right {
  width: 30%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  margin: 2px;
  border: 2px solid #cecece;
  box-shadow: 0 4px 8px rgba(126, 113, 113, 0.2); /* 添加阴影 */
}
.container .main .content {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 2px;
  border: 2px solid #cecece;
  box-shadow: 0 4px 8px rgba(126, 113, 113, 0.2); /* 添加阴影 */
}
.title {
  font-size: 32px;
  font-weight: bold;
  flex: 1;
  margin: 40px 0 25px 0;
}
.sideBar {
  position: absolute;
  bottom: 20px;
  right: 0;
  margin-right: 40px;
}
.sideBar .el-button .el-button--default {
  margin-right: 20px;
}
.main .main_title {
  font-size: 24px;
  font-weight: bold;
  margin: 20px 0;
  /* height: 10%; */
}
.main #left_echarts,
.main #content_echarts,
.main #right_echarts {
  flex: 1;
}
</style>
